home *** CD-ROM | disk | FTP | other *** search
/ PC Open 93 / PC Open 93 CD 2.bin / PDF / webdeveloper / lezione_4 / modificafoto_risposta.asp < prev    next >
Encoding:
Text File  |  2003-12-03  |  2.2 KB  |  87 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2.  
  3. <html>
  4. <head>
  5.     <title>Gestione foto di Mario Rossi</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <h1>Modifica di una foto</h1>
  11.  
  12. <%
  13.  
  14. Const adOpenForwardOnly = 0
  15. Const adLockReadOnly = 1
  16.  
  17. Dim contatore
  18. Dim sql1,sql2
  19. Dim conn, rs
  20. Dim i,j
  21.  
  22. Dim strNome, strTitolo, strData, strLuogo, strProvincia, strStato
  23.  
  24. strNome = request.Form("nome")
  25. strTitolo = request.Form("titolo")
  26. strData = request.Form("datagg") & "/" & request.Form("datamm") & "/" & request.Form("datayyyy")
  27. strLuogo = request.Form("luogo")
  28. strProvincia = request.Form("provincia")
  29. strStato = request.Form("stato")
  30.  
  31. Set conn = Server.CreateObject("ADODB.Connection")
  32. conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/foto2.mdb")
  33.  
  34. If Not IsDate(strData) Then
  35.     'Data in formato non valido
  36.     response.write "La data inserita (" & strData & ") non Φ valida<br>"
  37.     response.write "Ritorna alla<a href=""gestione.asp"">pagina di gestione</a>"
  38.     response.end
  39. End If
  40.  
  41. 'Rinforzo l'accento per evitare problemi in inserimento
  42. strTitolo = replace(strTitolo,"'","''")
  43. strLuogo = replace(strLuogo,"'","''")
  44.  
  45. sql = "UPDATE Foto SET " & _
  46.     " Foto.Data = '" & strData & "', " & _
  47.     " Foto.Titolo = '" & strTitolo & "'," & _
  48.     " Foto.Luogo = '" & strLuogo & "', " & _
  49.     " Foto.IdProvincia = '" & strProvincia & "', " & _
  50.     " Foto.IdStato = '" & strStato & "'" & _
  51.     " WHERE Foto.Nome = '" & strNome & "'"
  52.  
  53. on error resume next
  54.  
  55. conn.Execute sql
  56.  
  57. If ConnError(conn) > 0 Then
  58.     response.write "Si Φ verificato un problema con la modifica dei dati.<br>"
  59.     response.write "Ritorna alla <a href=""gestione.asp"">pagina di gestione</a>"
  60. Else
  61.     response.write "I dati della foto sono stati modificati correttamente<br>"
  62.     response.write "Ritorna alla <a href=""gestione.asp"">pagina di gestione</a>"
  63. End If
  64.  
  65. on error goto 0
  66.  
  67. set rs = nothing
  68. conn.close
  69. set conn = nothing
  70.  
  71. Function ConnError(conn)
  72.  
  73.   Dim i
  74.   i = 0
  75.  
  76.   For Each errorObject In conn.Errors
  77.       i = i + 1
  78.     Response.Write "ERRORE: " & errorObject.Description & "<br><br>"
  79.   Next
  80.  
  81.   ConnError = i
  82.  
  83. End Function
  84.  
  85. %>
  86.  
  87.